package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.base.util.BitStateUtil;
import cn.wolfcode.p2p.base.util.MaskUtil;
import lombok.Getter;
import lombok.Setter;

@Getter@Setter
public class UserInfo extends BaseDomain {
    private int version;//乐观锁
    private Long bitState = 0L;//用户状态码
    private String realName;//真实姓名
    private String idNumber;//身份证号码
    private String phoneNumber;//手机号码
    private String email;//邮箱
    private Long realAuthId; //实名认证Id
    private Long videoAuthId; //视频认证Id
    private SystemDictionaryItem incomeGrade;//收入情况
    private SystemDictionaryItem marriage;//婚姻情况
    private SystemDictionaryItem kidCount; //子女情况
    private SystemDictionaryItem educationBackground;//学历情况
    private SystemDictionaryItem houseCondition;//住房情况

    //是否有基本资料的填写
    public boolean getHasBasicInfo(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_BASICINFO);
    }

    //是否有实名认证
    public boolean getHasRealAuth(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_REALAUTH);
    }

    //是否有视频认证
    public boolean getHasVideoAuth(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_VIDEOAUTH);
    }

    //是否可借款
    public boolean getCanBorrow(){
        return this.getHasBasicInfo()&&this.getHasRealAuth()&&this.getHasVideoAuth();
    }

    //添加状态码
    public void addState(Long state) {
        this.bitState = BitStateUtil.addState(this.bitState, state);
    }

    //判断是否有正在借款的流程申请
    public boolean getHasBidRequestProcess(){
        return BitStateUtil.hasState(this.bitState, BitStateUtil.HAS_BIDREQUEST_PROCESS);
    }
    //删除状态码
    public void removeState(Long state) {
        this.bitState = BitStateUtil.removeState(this.bitState, state);
    }

    public String getAnonymousRealName() {
        return MaskUtil.getAnonymousRealName(realName);
    }

}
